package zisu.algorithm.algorithm.Trie;

import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        System.out.println("Pride and Prejudice");
        ArrayList<String> words = new ArrayList<>();
        if(FileOperation.readFile("pride-and-prejudice.txt",words)) {
            long startTime = System.nanoTime();
            BSTSet<String> bstSet = new BSTSet<>();
            for (String word : words) {
                bstSet.add(word);
            }

            for (String word : words) {
                bstSet.contains(word);
            }

            long endTime = System.nanoTime();
            double time = (endTime - startTime) / 1000000000.0;
            System.out.println("Total different words :" + bstSet.getSize());
            System.out.println("BSTSet : " + time + "s");

            System.out.println("===========================");

            ArrayList<String> words2 = new ArrayList<>();
            if (FileOperation.readFile("pride-and-prejudice.txt", words2)) {
                long startTime2 = System.nanoTime();
                Trie trie = new Trie();

                for (String word : words2) {
                    trie.add(word);
                }

                for (String word : words2) {
                    trie.contains(word);
                }

                long endTime2 = System.nanoTime();
                double time2 = (endTime2 - startTime2) / 1000000000.0;
                System.out.println("Total different words :" + trie.getSize());
                System.out.println("Trie : " + time2 + "s");


            }
        }
    }
}
